<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>校园用户注册</title>
<link rel="stylesheet" type="text/css" href="js/ext/resources/css/ext-all.css"/>
<script type="text/javascript" src="js/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="js/ext/ext-all.js"></script>
		<script type="text/javascript">
		Ext.onReady(function(){
				Ext.QuickTips.init();
				Ext.form.Field.prototype.msgTarget = 'side';
				Ext.apply(Ext.form.VTypes, {
						'userid': function(){
						var usernamePattern = /^[a-z0-9]/;
						return function(v){
            						 return usernamePattern.test(v);
        							 }
						}(),
						'useridText' : '用户名必须是英文小写字母或数字'
				});
				Ext.apply(Ext.form.VTypes, {
						'email': function(){
						var emailAddressPattern =/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
						return function(v){
            						 return emailAddressPattern.test(v);
        							 }
						}(),
						'emailText' : '请输入正确的E-Mail地址，如yourname@gmail.com'
				});
				var registerform=new Ext.form.FormPanel({
					 renderTo:"registerForm",
					 title:"校园用户注册",
					 height:260,
					 width:300,
					 frame:true,
					 labelAlign:"right",
					 labelWidth :70,
					 defaults :{width:160},
					 items:[
								{
									xtype:"textfield",
									id:"userid",
									name :"userid",
									fieldLabel :"用户名",
									allowBlank:false,
									blankText:"请填写用户名",
									minLength :6,
									minLengthText :"用户名长度至少6位",
									maxLength :12,
									maxLengthText :"用户名长度最多12位",
									vtype: 'userid'
									/*listeners:{
											"blur":function(){
														var uid=Ext.getCmp("userid").getValue();
													    alert(uid);
														this.load({
																		url:'http://127.0.0.1/cssp_m2/hasUser.action',
																		params:{userid:uid},
																		method :"get",
																		success :function(action,form){alert("success");},
																		failure :function(action,form){ alert("failure");}
																  });
													 }
											}*/
								},
								{
									xtype:"textfield",
									id:"password",
									name:"password",
									fieldLabel:"密码",
									inputType:"password",
									allowBlank:false,
									blankText:"请输入密码",
									minLength :6,
									minLengthText :"密码长度至少6位",
									maxLength :12,
									maxLengthText :"密码长度最多12位"
								},
								{
									xtype:"textfield",
									id:"repassword",
									name:"repassword",
									fieldLabel:"请确认密码",
									inputType:"password",
									allowBlank:false,
									blankText:"请输入确认密码",
									minLength :6,
									minLengthText :"密码长度至少6位",
									maxLength :12,
									maxLengthText :"密码长度最多12位",
									validator:function(){
										var pas=Ext.getCmp("password").getValue();
										var repas=Ext.getCmp("repassword").getValue();
										if(pas!=repas)
											{
												return "2次输入的密码不一致";
											}
										return true;
										}
								},
								{
									 xtype:"textfield",
									 fieldLabel: 'Email',
									 allowBlank:false,
									 blankText:"请输入E-Mail地址",
									 name: 'email',
									 vtype:'email'
            					}
								],
					 buttons:[
							  {
								  text:"提交",
								  handler :submit
							  },
							  {
								  text:"重置",
								   handler :reset
							  }
							  ]
					 });
				function submit(){ 
					if(registerform.form.isValid())
					{
						registerform.form.submit({
								waitTitle :"请稍候....",
								waitMsg :"正在提交，请稍候...",
								url:'http://127.0.0.1/cssp_m2/hasUser.action',
								method :"get",
								success :function(action,form){alert("success");},
								failure :function(action,form){ alert("failure");}
								});
					}
					}
				function reset(){
					registerform.form.reset();
					}
					
				
		})

</script>
</head>

<body>
<div id="registerForm" />
</body>
</html>
